package cn.tedu.file;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.Random;

public class TestOut2 {
    public static void main(String[] args) {
//        method();
        method2();
    }

    private static void method() {//测试普通字符输出流的方法
        Writer out=null;
        try {
            out=new FileWriter("G:\\ready\\1.txt",true);
            out.write(99);
            out.write(99);
            out.write(99);
            out.write(99);
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private static void method2() {
        Writer out=null;
        try {
            out=new BufferedWriter(new FileWriter("G:\\ready\\1.txt",true));
            out.write(100);
            out.flush();//防止数据遗漏，刷数据

        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
